﻿<script type="text/javascript">
        alert("请您一次完成调查问卷,中途退出不能保存答题记录");
        $(document).ready(function () {
            $("form").validate({
                rules: {
                    @foreach (var q in (System.Data.EnumerableRowCollection<System.Data.DataRow>)ViewBag.Q)
                    {
                        if (q["qtype"].ToString() == "mradio")
                        {
                            for (int i = 1; i < 12; i++)
                            {
                            <text>q@{@q["questionid"]}_@{@i}:"required",</text>
                            }
                        }
                        else if (q["qtype"].ToString() == "input")
                        { }
                        else
                        {
                        <text>q@{@q["questionid"]}:"required",</text>
                        }
                    }
                    qtest:"required"
                },
                messages: {
                     @foreach (var q in (System.Data.EnumerableRowCollection<System.Data.DataRow>)ViewBag.Q)
                     {
                         if (q["qtype"].ToString() == "mradio")
                         {
                             for (int i = 1; i < 12; i++)
                             {
                            <text>q@{@q["questionid"]}_@{@i}:"第@{@q["qorder"]}题第@{@i}项必答",</text>
                             }
                         }
                         else if (q["qtype"].ToString() == "input")
                         { }
                         else
                         {
                         <text>q@{@q["questionid"]}:"第@{@q["qorder"]}题必答",</text>
                         }
                     }
                     qtest:"required"
                },
                showErrors: function (errorMap, errorList) {
                    var msg = "";
                    $.each(errorList, function (i, v) {
                        msg += (v.message + "\r\n");
                    });
                    if (msg != "") alert(msg);
                }
            })
        });


</script>
